//
//  MainViewController.swift
//  Weibo
//
//  Created by mac on 16/1/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    
    @objc private func plusBtnDidClick() {
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()
       
        let mainTabbar = MainTabbar()
        setValue(mainTabbar, forKey: "tabBar")
        
        mainTabbar.plusBtn.addTarget(self, action: "plusBtnDidClick", forControlEvents: .TouchUpInside)
        addChildViewControllers()
    }
    
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), imageName: "tabbar_home", title: "首页")
        addChildViewController(MessageTableViewController(), imageName: "tabbar_message_center", title: "消息")
        addChildViewController(DiscoverTableViewController(), imageName: "tabbar_discover", title: "发现")
        addChildViewController(ProfileTableViewController(), imageName: "tabbar_profile", title: "我")
    }

    private func addChildViewController(vc: UIViewController,imageName: String,title: String){
        
        vc.tabBarItem.image = UIImage(named: imageName)
        self.tabBar.tintColor = UIColor.orangeColor()
//        vc.tabBarItem.selectedImage = UIImage(named: imageName+"_highlighted")?.imageWithRenderingMode(.AlwaysOriginal)
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Selected)
//        home.tabBarItem.title = "首页"
//        home.navigationItem.title = "首页"
        vc.title = title
        let nav = UINavigationController(rootViewController: vc)
        
        addChildViewController(nav)
    }

}
